<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户列表</title>
<link rel="stylesheet" href="${path}/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${path}/css/system.css">
<script src="${path}/bootstrap/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${path}/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container-fluid" >
		<div>
			<ol class="breadcrumb">
			  <li><a href="#">当前位置:主页</a></li>
			  <li><a href="#">用户管理</a></li>
			  <li class="active">用户列表</li>
			</ol>		
			<div class="search_content" style="vertical-align: middle;padding-left: 15px;">
				
				用户名：<input type="text" id="username" name="username" style="width:150px" value="${param.username}"/>&nbsp;&nbsp;
				<a  href="javascript:search()" class="btn btn-primary btn-xs ">查询</a>
				<a href="${path}/user.do?method=addUI" class="btn btn-primary btn-xs ">添加</a>
				<script>
					function search(){
						var username = $("#username").val();
						location.href="${path}/user.do?method=list&username="+username;


					}
				</script>
				
			</div><br>
			<div class="page">
				<table class="table table-hover table-bordered">
					<tr>
						<th>序号</th>
						<th>用户名</th>
						<th>用户状态</th>
						<th>角色</th>
						<th>手机号</th>
						<th>操作</th>
					</tr>
					<c:forEach items="${list}" var="user" varStatus="in">
					<tr>
						<td>${(currentPage-1)*pageSize+in.count}</td>
						<td>${user.username}</td>
						<td>${user.status==1?"可用账户":"已禁用"}</td>
						<td>
							<c:forEach items="${user.roles}" var="role">
								${role.rname} &nbsp;&nbsp;


							</c:forEach>

						</td>
						<td>${user.phone}</td>
						<td>
							<a href="${path}/user.do?method=editUI&uid=${user.uid}" class="btn btn-xs btn-info" type="button">修改</a>
							<c:choose>
								<c:when test="${user.status==0}">
									<a href="javascript:del(${user.uid},'${user.username}')"class="btn btn-xs btn-danger" type="button">启用</a>


								</c:when>
								<c:otherwise>
									<a href="javascript:del(${user.uid},'${user.username}')"class="btn btn-xs btn-danger" type="button">禁用</a>

								</c:otherwise>
							</c:choose>

							<a href="javascript:resetPwd(${user.uid},'${user.username}')" class="btn btn-xs btn-danger" type="button">重置密码</a>
							<script>
								function del(uid,username){
									if(confirm("你确认启用/禁用"+username+"吗？")){
										location.href="${path}/user.do?method=del&uid="+uid;
									};

								}
								function resetPwd(uid,username){
									if(confirm("你确认将"+username+"的密码重置为123456吗？")){
										location.href="${path}/user.do?method=resetPwd&uid="+uid;
									};


								}
							</script>
						</td>
					</tr>
					</c:forEach>
					<%--<tr>
						<td>2</td>
						<td>张三</td>
						<td>市场部咨询</td>
						<td>138389438</td>
						<td>
							<a href="update.jsp" class="btn btn-xs btn-info" type="button">修改</a>
							<a class="btn btn-xs btn-danger" type="button">删除</a>
							<a class="btn btn-xs btn-danger" type="button">重置密码</a>
						</td>
					</tr>--%>


					<tr>
						<td colspan="6" align="center">
							<a href="${path}/user.do?method=list&currentPage=1&username=${param.username}">首页</a>
							<a href="${path}/user.do?method=list&currentPage=${currentPage-1}&username=${param.username}">上一页</a>
							<a href="${path}/user.do?method=list&currentPage=${currentPage+1}&username=${param.username}">下一页</a>
							<a href="${path}/user.do?method=list&currentPage=${pageNum}&username=${param.username}">尾页</a>
                            当前${currentPage}/${pageNum}页，总共${total}条记录。
						</td>
					</tr>
				</table>	
			</div>
		</div>
	</div>
</body>
</html>